package com.xy.tx;


import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class TxClient {
    /**
     *    腾讯云账户密钥 secretId. TODO 修改为自己账户的secretId
     */
    public static final String SECRET_ID = "AKIDQp4A9xkNtGTVM6g8SejiYDgw44xUs57z";
    /**
     *  腾讯云账户密钥 secretKey. TODO 修改为自己账户的secretKey
     *
	 */
    public static final String SECRET_KEY = "pSuCKK8mDWcVVM2VxEPRK4hATcdXHqHa";

    public static Credential cred;
    public static ClientProfile clientProfile;

    /**
     * 初始化腾讯客户端
     */
	@Bean
    public static void initclientProfileClient() {
        cred = new Credential(SECRET_ID, SECRET_KEY);
        log.info("初始化initCredentialClient实例成功");
        //region 设置http选项中的参数
        HttpProfile httpProfile = new HttpProfile();
        // post请求  (默认为post请求)
        httpProfile.setReqMethod(HttpProfile.REQ_POST);
        // 指定接入地域域名(默认就近接入)
        //httpProfile.setEndpoint(ENDPOINT);
        //httpProfile.setRootDomain(ROOT_DOMAIN);
        // 在外网互通的网络环境下支持http协议(默认是https协议),请选择(https:// or http://)
        httpProfile.setProtocol(HttpProfile.REQ_HTTPS);
        // 设置读取超时时间，单位为秒(默认0秒)
        httpProfile.setReadTimeout(0);
        // 设置写入超时时间，单位为秒(默认0秒)
        httpProfile.setWriteTimeout(0);
        // 请求连接超时时间，单位为秒(默认60秒)
        httpProfile.setConnTimeout(HttpProfile.TM_MINUTE);
        //httpProfile.setEndpoint("ocr.tencentcloudapi.com");
        //region 设置client选项中的参数
        clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);
        // 指定签名算法默认（"TC3-HMAC-SHA256"），它更安全但是会轻微降低性能。
        clientProfile.setSignMethod(ClientProfile.SIGN_TC3_256);
        //打印日志，默认是false
        clientProfile.setDebug(true);
        log.info("初始化initclientProfileClient实例成功");
    }
}
